package cn.dida.util;

import java.util.Stack;
/**
 * 类型转换工具类
 * @author weiwei
 *
 */
public class NumberConvetUtil {

	public static final String SIXTY_CONVET = "0123456789abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXYZ";
	
	/** 
     * 将数转为任意进制 
     * @param num 
     * @param base 
     * @return 
     */  
    public static String baseString(Long num,String digths){  
    	
    	int base = digths.length();
    	
    	StringBuffer str = new StringBuffer("");  
        Stack<Character> s = new Stack<Character>();  
        while(num != 0){  
            s.push(digths.charAt((int) (num%base)));  
            num/=base;  
        }  
        while(!s.isEmpty()){  
            str.append(s.pop());  
        }  
        int n = str.length();
        StringBuffer zerostr = new StringBuffer("");
        if(n<6){
        	
        	for(int i=0;i<(6-n);i++){
        		zerostr.append("0");
        	}
        }
        
        return zerostr.append(str).toString();  
    }  
    
    
		public static void main(String[] args) {
		
			System.out.println(NumberConvetUtil.baseString(58L, NumberConvetUtil.SIXTY_CONVET));
		}
  
}
